package cn.texous.dns.configure;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * insert description here
 *
 * @author Showa.L
 * @since 2019/7/5 9:41
 */
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "other")
public class OtherProperties {

    private Ip ip;
    private Mail mail;

    /***/
    @Data
    public static class Ip {
        private List<String> whitelist;
    }

    /***/
    @Data
    public static class Mail {
        private String registerSubject;
        private String loginSubject;
        private String changePwdSubject;
        private String registerContent;
        private String loginContent;
        private String changePwdContent;
        private String registerHtml;
        private String loginHtml;
        private String changePwdHtml;

        /***/
        public String getSubject(Integer bt) {
            switch (bt) {
                case 1:
                    return registerSubject;
                case 2:
                    return loginSubject;
                case 3:
                    return changePwdSubject;
                default:
                    return registerSubject;
            }
        }

        /***/
        public String getContent(Integer bt) {
            switch (bt) {
                case 1:
                    return registerContent;
                case 2:
                    return loginContent;
                case 3:
                    return changePwdContent;
                default:
                    return registerContent;
            }
        }

        /***/
        public String getHtml(Integer bt) {
            switch (bt) {
                case 1:
                    return registerHtml;
                case 2:
                    return loginHtml;
                case 3:
                    return changePwdHtml;
                default:
                    return registerHtml;
            }
        }
    }
}
